package com.example.bittraffic;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;

public class Activity_Main extends Activity {

	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		menu.setQwertyMode(true);

		menu.add(0, 0, 0, "광주맛집").setAlphabeticShortcut('a')
				.setIcon(R.drawable.image_restaurant);
		//
		// menu.add(0, 1, 1, "지하철").setAlphabeticShortcut('b')
		// .setIcon(R.drawable.image_subway);

		// menu.add(0, 2, 2, "광주콜밴").setAlphabeticShortcut('c')
		// .setIcon(R.drawable.image_taxi);

		SubMenu sm = menu.addSubMenu(0, 2, 2, "광주신문").setIcon(
				R.drawable.imgae_news);
		sm.add(1, 3, 3, "광주사랑방신문");
		sm.add(1, 4, 4, "광주매일신문");
		sm.add(1, 5, 5, "전남일보");
		return true;
	}

	public boolean onOptionsItemSelected(MenuItem item) {
		if (item.getItemId() == 0) {
			Intent intent = new Intent(getApplicationContext(),
					Activity_Food.class);
			startActivity(intent);
			finish();
		}
		if (item.getItemId() == 1) {
			Intent intent = new Intent(getApplicationContext(),
					Activity_Subway.class);
			startActivity(intent);
			finish();
		}
		if (item.getItemId() == 3) {
			Intent intent = new Intent(getApplicationContext(),
					Activity_News.class);
			startActivity(intent);
			finish();

		}
		if (item.getItemId() == 4) {
			Intent intent = new Intent(getApplicationContext(),
					Activity_News2.class);
			startActivity(intent);
			finish();

		}
		if (item.getItemId() == 5) {
			Intent intent = new Intent(getApplicationContext(),
					Activity_News3.class);
			startActivity(intent);
			finish();

		}
		return false;

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		switch (keyCode) {
		case KeyEvent.KEYCODE_BACK:
			Activity_Exit cdd = new Activity_Exit(Activity_Main.this);
			cdd.show();
		}
		// switch (keyCode) {
		// case KeyEvent.KEYCODE_BACK:
		// new AlertDialog.Builder(Activity_Main.this)
		// .setTitle("종료")
		// .setMessage("프로그램을 완전히 종료합니다.\n종료 하시겠습니까?")
		// .setPositiveButton("예",
		// new DialogInterface.OnClickListener() {
		//
		// @Override
		// public void onClick(DialogInterface dialog,
		// int which) {
		// moveTaskToBack(true);
		// finish();
		// }
		// }).setNegativeButton("아니오", null).show();
		// }
		return super.onKeyDown(keyCode, event);
	}

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main2);

		Intent intent = getIntent();
		int load = intent.getIntExtra("load", 0);
		if (load == 0) {
			startActivity(new Intent(this, Activity_Loading.class));
		}
		load = 1;
	}

	public void onClick_busPage(View v) {
		Intent intent = new Intent(getApplicationContext(),
				Activity_Bus_PlanB.class);
		startActivity(intent);
		// Intent intent = new Intent(Intent.ACTION_VIEW);
		// intent.setData(Uri
		// .parse("http://bus.gjcity.net:7001/app/mobile/m_main.jsp"));
		// startActivity(intent);
		// finish();
	}

	public void onClick_subwayPage(View v) {
		Intent intent = new Intent(getApplicationContext(),
				Activity_Subway.class);
		startActivity(intent);
	}

	public void onClick_taxiPage(View v) {
		Intent intent = new Intent(getApplicationContext(), Activity_Taxi.class);
		startActivity(intent);
	}
}